﻿using Resources;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Resources;
using System.Threading;
using System.Web;

/// <summary>
/// LanguageUtil 的摘要描述
/// </summary>
public class LanguageUtil
{
  public LanguageUtil()
  {
    //
    // TODO: 在這裡新增建構函式邏輯
    //
  }

  public static IEnumerable<KeyValuePair<string, string>> GetItemsFromResource(ResourceManager resourceManager)
  {
    var resourceSet = resourceManager.GetResourceSet(Thread.CurrentThread.CurrentUICulture, true, true);
    return from entry in resourceSet.Cast<DictionaryEntry>()         
           select new KeyValuePair<string, string>(entry.Key.ToString(), entry.Value.ToString());
  }

  public static IEnumerable<KeyValuePair<string, string>> GetItemsFromResource(string prefix, ResourceManager resourceManager)
  {    
    var resourceSet = resourceManager.GetResourceSet(Thread.CurrentThread.CurrentUICulture,true, true);
    return from entry in resourceSet.Cast<DictionaryEntry>()
           where entry.Key.ToString().StartsWith(prefix)
           select new KeyValuePair<string, string>(entry.Key.ToString().Substring(prefix.Length + 1), entry.Value.ToString());
  }
}